package com.link2room.rodimus.nmsrunner;

import com.aliyun.mns.model.Message;
import com.link2room.common.mns.Worker;
import com.link2room.common.util.ExceptionUtil;
import com.link2room.common.util.JacksonUtil;
import com.link2room.rodimus.facade.IAfterPMSdepDoFacadeService;
import com.link2room.soundwave.dto.param.inside.PmsReservationInsideParamDto;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * Created by sss on 2016/9/21.
 */
@Component("pmsCheckOutDoRunner")
public class PmsCheckOutDoRunnerImpl implements Worker {
    @Resource
    private IAfterPMSdepDoFacadeService commentFacadeService;
    @Resource
    private IAfterPMSdepDoFacadeService couponFacadeService;

    @Override
    public boolean exec(Message message) throws Exception {
        try{
            PmsReservationInsideParamDto pmsReservationInsideParamDto = JacksonUtil.jsonToBean(message.getMessageBody(), PmsReservationInsideParamDto.class);
            if(message.getDequeueCount()==1){
                commentFacadeService.syncAfterPMSDepDo(pmsReservationInsideParamDto);
                couponFacadeService.syncAfterPMSDepDo(pmsReservationInsideParamDto);
            }
        }catch (Exception e){
            ExceptionUtil.getExceptionDetail(e);
            e.printStackTrace();
        }finally {
            return true;

        }
    }
}
